<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/react.js"></script>
    <script src="js/react-dom.js"></script>
    <script src="js/browser.min.js"></script>
    <script></script>
</head>
<body>
    <div id='example'></div>

    <script type="text/babel">
        var TestComponent = React.createClass({
            //完成了状态的初始化操作
            getInitialState:function(){
                return {
                    opacityValue:0.1
                }
            },
            componentDidMount:function(){
                //启动一个周期性定时器
                setInterval(()=>{
                    //将状态中的值 修改 0.1
                    var nowValue = this.state.opacityValue;
                    
                    nowValue+=0.1;

                    if(nowValue > 1){
                        nowValue = 0;
                    }

                    this.setState({opacityValue:nowValue});
                },500);
            },
            render:function(){
                return <p style=
                {{opacity:this.state.opacityValue}}>Hello React</p>
            }
        });

        ReactDOM.render(
            <TestComponent></TestComponent>,
            document.getElementById('example')
        );
    </script>
</body>
</html>